﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.Globalization;
using Legend.Tests;

namespace Legend.Core.Tests
{
    [TestFixture]
    public class SystemExtensionsTests
    {
        [Test]
        public void FormatInvariant_formats_the_string_correctly()
        {
            var formatted = "foo {0} bar".FormatInvariant(new DateTime(2000, 1, 1));
            Assert.AreEqual("foo 2000-01-01 00:00:00 bar" ,formatted);
        }

        [Test]
        public void Format_formats_the_string_correctly()
        {
            var formatted = "foo {0} bar".Format(CultureInfo.GetCultureInfo("en-US"), new DateTime(2000, 1, 1));
            Assert.AreEqual("foo 1/1/2000 12:00:00 AM bar", formatted);
        }

        [Test]
        [SetCulture("en-US")]
        public void Format_formats_the_string_using_the_current_culture()
        {
            var formatted = "foo {0} bar".Format(new DateTime(2000, 1, 1));

            Assert.That(formatted, Is.EqualTo("foo 1/1/2000 12:00:00 AM bar"));
        }

        [Test]
        public void Guid_ToShortString_should_return_expected_string()
        {
            // Arrange
            var guid = new Guid("b050bfdc-3fbf-443a-8520-5badffecbff7");
            

            // Act
            var result = guid.ToShortString();

            // Assert
            Assert.That(result, Is.EqualTo("3L9QsL8_OkSFIFut_-y_9w"));
        }
    }
}
